#ifndef __SPI_H
#define __SPI_H
#include "sys.h"

#define	SPI2_CS  PBout(12)

#define READ_MEM 0x08
#define WRITE_MEM 0x04
#define FP_DATBUF_LEN 256
#define HEARTBEAT_ADDR		0x20010000
#define VS_ADDR				0x20010100
#define SDINF_ADDR			0x20010200
#define CONFIG_SEND_ADDR	0x20010500
#define FPGA_MODE_ADDR		0x20010600

//extern u8 spi2_data[];
//extern u8 fpga_databuf[];
extern	u8 rec_buf_data[256];

extern void SPI2_Init(void);

extern u8 Set_FPGA_Mode(u8 mode);
extern u8 Get_FPGA_State(void);
extern void cmd_line_heartbeat (void);
extern void cmd_line_file_information (void);
extern void cmd_line_display_information(u32 sector_addr,u16 infile_addr,u32 total_num,u16 row_num,u16 column_num,u16 freq_A);
extern void offline_vs_on (void);
extern void offline_vs_off (void);
extern void send_config_en(u8 config_en);
extern void send_config_data (u16 config_addr,u8 *data_ptr);

u8 FPGA_trans_write(u32 mem_addr,u8 *data_ptr,u16 data_len);
u8 FPGA_trans_read(u32 mem_addr,u8 *data_ptr,u16 data_len);

void gentx_data(u32 mem_addr,u8 *data_ptr,u16 data_len,u8 mem_rw);
u8 FPGA_write_ack(void);
u8 get_rx_data(u16 data_len);
u8 SPI2_ReadWriteByte(u8 TxData);

void gen_normal_table(u32 *table);
u32 Reverse_Table_CRC(u8 *data, u32 len, u32 * table);
u32 Reflect(u32 ref,u8 ch);

//extern void FPGA_data_trans(u32 mem_addr,u8 *data_ptr,u16 data_len,u8 mem_rw);
//extern u8 FPGA_data_rec(u8 *data_ptr,u16 data_len);
//extern u32 spi2_datatrans_crc(u8 data);

#endif

